<style lang="less">
</style>

<template>
  <div>
    <iview-table
            ref="table"
            :data="data"
            :baseURL="queryModel.baseURL"
            :menuId="dataModel.menuId"
            :columns="dataModel.columns"
            :order="dataModel.order"
            :pageNumber="pageModel.pageNumber"
            :pageSize="pageModel.pageSize"
            :defaultFilters="queryModel.defaultFilters"
            v-on="{changeTotalSize:changeTotalSize,changeSelect:changeSelect}">
    </iview-table>
  </div>
</template>

<script>
    import iviewTable from '@/view/common/table/Table.vue';
    import iviewPage from '@/view/common/page/Page.vue';
    export default {
        components: {
            iviewTable,
            iviewPage
        },
        props: {
            patientId: {
                type: Number,
                default: -1
            },
            data: {
                type: Array,
                default: []
            }
        },
        data () {
            return {
                baseURL: '/user/deduct',
                selectRows: [],
                queryModel: {
                    // 网关代理路径(必须)+资源路径(可选)
                    baseURL: '/user/deduct',
                    defaultFilters: [
                        {'field': 'patient_id', 'value1': -1, 'operate': '=='}
                    ]
                },
                dataModel: {
                    menuId: -1,
                    columns: [
                        {
                            title: '划扣时间',
                            key: 'creationTime',
                            render: (h, params) => {
                                return this.$moment(params.row.creationTime).format('YYYY年MM月DD日')
                            }
                        },{
                            title: '项目来源',
                            key: 'treatName'
                        },{
                            title: '项目/产品',
                            key: 'itemName'
                        },{
                            title: '单次划扣金额',
                            key: 'price'
                        },{
                            title: '本次划扣(次数/数量)',
                            key: 'deductCount'
                        },{
                            title: '本次划扣金额',
                            key: 'deductAmount'
                        }
                    ],
                    order: 'creation_time asc'
                },
                pageModel: {
                    totalSize: 0,
                    pageNumber: 1,
                    pageSize: 10,
                    pageSizeOpts: [10, 50, 100, 500]
                }
            };
        },
        methods: {
            changeSelect (rows) {
                this.selectRows = rows
            },
            changeTotalSize (totalSize) {
                this.pageModel.totalSize = totalSize
            },
            changePageNumber (pageNumber) {
                this.pageModel.pageNumber = pageNumber
            },
            changePageSize (pageSize) {
                this.pageModel.pageSize = pageSize
            },
            refresh () {
                this.$refs.table.refresh()
            },
            init () {
                this.refresh()
            }
        },
        mounted () {
            this.init()
        },
        watch: {
            patientId: function (val, oldVal) {
                this.queryModel.defaultFilters[0] = {'field': 'patient_id', 'value1': val, 'operate': '=='}
            }
        }
    }
</script>

<style>

</style>
